﻿using MediatR;
using SheepStorage.API.Application.Command.SheepMomDeliveryCommand;
using SheepStorage.API.Application.Command.SheepMomPergnantCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepMomDeliveryHandler
{
    public class SheepMomDeliveryShowCommandHandler : IRequestHandler<SheepMomDeliveryShowCommand, Results<List<SheepMomDeliveryDto>>>
    {


        private readonly ISheepMomDeliveryService SheepMomDeliveryService;
        public SheepMomDeliveryShowCommandHandler(ISheepMomDeliveryService SheepMomDeliveryService)
        {
            this.SheepMomDeliveryService = SheepMomDeliveryService;
        }

        public async Task<Results<List<SheepMomDeliveryDto>>> Handle(SheepMomDeliveryShowCommand request, CancellationToken cancellationToken)
        {
            var entity = await SheepMomDeliveryService.GetSheepMomDelivery(request.endTime, request.startTime, request.OverBit, request.MomPergnantPrincipal,request.BuildingManagementId, request.DeliverySlowId);
            if (entity == null)
            {
                return Results<List<SheepMomDeliveryDto>>.FailResult();
            }
            return Results<List<SheepMomDeliveryDto>>.DataResult(entity);
        }
    }
}
